<script lang="ts" setup>
import { ref, reactive, onMounted } from 'vue';
import { ElMessage, FormInstance, FormRules, genFileId, UploadFile, UploadFiles, UploadInstance, UploadProps, UploadRawFile } from 'element-plus';
import useStore from '@/store';
import { props } from './xytable';
defineOptions({ name: 'XYTableForm' });
const _props = defineProps(props);
const tableRef = ref(null);
const loading = ref(false);
const loadingDownload = ref(false);
const view = ref(_props.window);
const form = reactive({
  title: null,
  warehouseId: null,
  warehouseCode: null,
  lensId: null,
  lensCode: null,
  xyTable: null,
});
const showXYTable = () => {
  loading.value = true;
  window.$api.common.getXYTableView(_props.window.params).then(res => {
    view.value.label = res.data.title;
    form.title = res.data.title;
    form.warehouseId = res.data.warehouseId;
    form.warehouseCode = res.data.warehouseCode;
    form.lensId = res.data.lensId;
    form.lensCode = res.data.lensCode;
    form.xyTable = res.data.xyTable;
    loading.value = false;
  });
};
const downLoadXYTableExcel = () => {
  loadingDownload.value = true;
  window.$api.common.downLoadXYTableExcel(form).then(res => {
    loadingDownload.value = false;
  });
};
onMounted(() => {
  showXYTable();
});
</script>

<template>
  <windows-window :window="view" v-loading="loadingDownload">
    <template #button>
      <windows-button-group size="18">
        <windows-button icon="fluent-save-28-regular" @click="downLoadXYTableExcel">下载Excel</windows-button>
      </windows-button-group>
    </template>
    <el-table ref="tableRef" :data="form.xyTable" style="width: 100%" highlight-current-row v-loading="loading" border>
      <el-table-column prop="sph" label="SPH" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="000" label="000" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-025" label="-025" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-050" label="-050" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-075" label="-075" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-100" label="-100" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-125" label="-125" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-150" label="-150" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-175" label="-175" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-200" label="-200" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-225" label="-225" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-250" label="-250" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-275" label="-275" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-300" label="-300" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-325" label="-325" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-350" label="-350" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-375" label="-375" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-400" label="-400" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-425" label="-425" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-450" label="-450" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-475" label="-475" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-500" label="-500" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-525" label="-525" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-550" label="-550" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-575" label="-575" align="center" minWidth="80" show-overflow-tooltip></el-table-column>
      <el-table-column prop="-600" label="-600" align="center" minWidth="60" show-overflow-tooltip></el-table-column>
      <el-table-column prop="total" label="Total" align="center" minWidth="60" show-overflow-tooltip fixed="right"></el-table-column>
    </el-table>
  </windows-window>
</template>

<style scoped lang="scss">
#edit {
  height: 100%;
}
.el-form {
  margin: 30px 20px;
  .el-upload-dragger {
    padding: 0;
  }
}
.custom-node {
  display: flex;
  align-items: center;
  span {
    margin-left: 5px;
  }
}
.select-icon {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  border: 1px solid #dcdfe6;
  border-radius: 5px;
  margin-top: 5px;
  background: #fff;
  width: 100%;
  height: 200px;
  overflow: auto;
  .el-image {
    margin: 10px;
    cursor: pointer;
    border-radius: 5px;
    padding: 5px;
    &:hover,
    &.active {
      background: #dcdfe6;
    }
  }
}
</style>
